package com.jxtc.enterprise.common.constants;

import com.jxtc.enterprise.common.entity.MenuStoreConfig;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * 按照常人的饮食习惯，定义基础餐饮类型，不同场景的需求可以通过如下6中最基本的餐饮类型进行组合
 * 比如 会议餐 = 上午茶 + 午餐 + 下午茶 + 晚餐；
 * 中秋公司团建 = 午餐 + 下午茶 + 晚餐
 * 双11技术保障 = 晚餐 + 夜宵
 *
 */
@Slf4j
public enum MealTypeEnum {

    BREAK_FAST(1, "breakFast", "早餐", "19:00:00", "08:30:00", "08:35:00", "09:15:00", 1, "08:55:00"),
    LUNCH(2, "lunch", "午餐", "19:00:00", "10:30:00", "10:35:00","11:45:00",1, "10:55:00"),
    DINNER(3, "dinner", "晚餐","15:00:00", "17:30:00", "17:35:00","18:45:00",1, "17:55:00"),
    MORNING_TEA(4, "morningTea", "上午茶","19:00:00", "10:00:00", "10:05:00","10:30:00",1, "10:15:00"),
    AFTERNOON_TEA(5, "afterNoonTea", "下午茶","15:00:00", "16:00:00", "16:05:00","16:30:00",1, "16:10:00"),
    NIGHT_SNACK(6, "nightSnack", "夜宵","10:00:00", "20:30:00", "20:35:00","21:35:00",1, "20:55:00"),
    ;

    /**
     * 数字编码
     */
    private int code;

    /**
     * 英文名称
     */
    private String mealTypeEn;

    /**
     * 中文名称
     */
    private String mealTypeCn;


    private String startTime;

    private String endTime;

    private String canCancelTime;

    private String deliveryTime;

    /**
     * 打印方式， 1 批量打印，2 一单一打印
     */
    private int printType;

    /**
     * 打印方式， 1 批量打印，2 一单一打印
     * 将 字符串 转换为 数值，页面与 后端服务之间的接口和返回值中，使用数值，便于前段传参和 编写逻辑时使用
     * 数据库存放的是字符串，便于定位问题时 查看数据
     * @param printTypeStr
     * @return
     */
    public static int convertPrintTypeStringToInt(String printTypeStr) {
        return printTypeStr.equalsIgnoreCase("batch") ? 1 : 2;
    }

    /**
     * 打印方式， 1 批量打印，2 一单一打印
     * 将 数值 转换为 字符串，页面与 后端服务之间的接口和返回值中，使用数值，便于前段传参和 编写逻辑时使用
     * 数据库存放的是字符串，便于定位问题时 查看数据
     * @param printTypeInt
     * @return
     */
    public static String convertPrintTypeIntToString(int printTypeInt) {
        return printTypeInt == 1  ? "batch" : "single";
    }


    private String printTime;

    MealTypeEnum(int code, String mealTypeEn, String mealTypeCn, String startTime,
                 String endTime, String canCancelTime, String deliveryTime,
                 int printType, String printTime) {
        this.code = code;
        this.mealTypeEn = mealTypeEn;
        this.mealTypeCn = mealTypeCn;
        this.startTime = startTime;
        this.endTime = endTime;
        this.canCancelTime = canCancelTime;
        this.deliveryTime = deliveryTime;
        this.printType = printType;
        this.printTime = printTime;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMealTypeEn() {
        return mealTypeEn;
    }

    public void setMealTypeEn(String mealTypeEn) {
        this.mealTypeEn = mealTypeEn;
    }

    public String getMealTypeCn() {
        return mealTypeCn;
    }

    public void setMealTypeCn(String mealTypeCn) {
        this.mealTypeCn = mealTypeCn;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getCanCancelTime() {
        return canCancelTime;
    }

    public void setCanCancelTime(String canCancelTime) {
        this.canCancelTime = canCancelTime;
    }

    public String getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(String deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    public int getPrintType() {
        return printType;
    }

    public void setPrintType(int printType) {
        this.printType = printType;
    }

    public String getPrintTime() {
        return printTime;
    }

    public void setPrintTime(String printTime) {
        this.printTime = printTime;
    }


    /**
     * 根据 用餐时段 英文名称，获取对应的 枚举项
     * @param mealTypeNameEn
     * @return
     */
    public static MealTypeEnum getMealTypeEnumByNameEn(String mealTypeNameEn) {

        switch(mealTypeNameEn) {
            case "breakFast":
                return MealTypeEnum.BREAK_FAST;
            case "lunch":
                return MealTypeEnum.LUNCH;
            case "dinner":
                return MealTypeEnum.DINNER;
            case "morningTea":
                return MealTypeEnum.MORNING_TEA;
            case "afterNoonTea":
                return MealTypeEnum.AFTERNOON_TEA;
            case "nightSnack":
                return MealTypeEnum.NIGHT_SNACK;
            default:
                log.error("mealTypeNameEn: {} 不是有效的,有效值为 [breakFast,lunch,dinner,morningTea,afterNoonTea,nightSnack ]", mealTypeNameEn);
                return MealTypeEnum.LUNCH;
        }
    }

    public static String convertMealTypeEnToCn(String mealTypeEn) {

        switch(mealTypeEn) {
            case "breakFast":
                return MealTypeEnum.BREAK_FAST.mealTypeCn;
            case "lunch":
                return MealTypeEnum.LUNCH.mealTypeCn;
            case "dinner":
                return MealTypeEnum.DINNER.mealTypeCn;
            case "morningTea":
                return MealTypeEnum.MORNING_TEA.mealTypeCn;
            case "afterNoonTea":
                return MealTypeEnum.AFTERNOON_TEA.mealTypeCn;
            case "nightSnack":
                return MealTypeEnum.NIGHT_SNACK.mealTypeCn;
            default:
                log.error("mealTypeNameEn: {} 不是有效的,有效值为 [breakFast,lunch,dinner,morningTea,afterNoonTea,nightSnack ]", mealTypeEn);
                return MealTypeEnum.LUNCH.mealTypeCn;

        }
    }

}
